

#include "weak_ptr.h"

#include <string>

#include "a_self.h"
#include "b_self.h"
#include "shared_ptr.h"

using namespace utility;
using std::string;

class Test {
public:
    Test() = default;
    ~Test() { std::cout << "Test is deleted" << std::endl; }

    void setName(const string& name) { _name = name; }
    string getName() const { return _name; }

private:
    string _name;
};

int main() {
    SharedPtr<A> a(new A);
    SharedPtr<B> b(new B);

    std::cout << "A Used: " << a.use_count() << std::endl;
    std::cout << "B Used: " << b.use_count() << std::endl;

    a->_b = b;
    b->_a = a;

    std::cout << "A Used: " << a.use_count() << std::endl;
    std::cout << "B Used: " << b.use_count() << std::endl;

    return 0;
}